/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CongratulationsFrame.java
 *
 * Created on Jun 20, 2009, 8:59:14 PM
 */

package ces31.ChineseDicesClient.IU;

import ces31.ChineseDicesClient.SO_SistemaCliente;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Douglas
 */
public class IU_ResultadoFinal extends javax.swing.JFrame {

    /** Creates new form CongratulationsFrame */
    public IU_ResultadoFinal(String winner) {
        setNomeVencedor(winner);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        areaVencedor = new javax.swing.JLabel();
        imagemFinal = new javax.swing.JLabel();
        botaoSair = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        areaVencedor.setFont(new java.awt.Font("Calibri", 1, 36));
        areaVencedor.setText(getNomeVencedor());
        areaVencedor.setName("areaVencedor"); // NOI18N

        imagemFinal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ces31/ChineseDicesClient/IU/dicemaster.png"))); // NOI18N
        imagemFinal.setName("imagemFinal"); // NOI18N

        botaoSair.setText("Sair");
        botaoSair.setName("botaoSair"); // NOI18N
        botaoSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairDoJogo(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addComponent(imagemFinal)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(170, Short.MAX_VALUE)
                .addComponent(botaoSair, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(areaVencedor)
                .addContainerGap(86, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addComponent(areaVencedor)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(imagemFinal)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(botaoSair)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void sairDoJogo(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairDoJogo
        this.setVisible(false);
        try {
            SO_SistemaCliente.getSalaDeEspera().desconectarCliente();
        } catch (Throwable ex) {
            Logger.getLogger(IU_ResultadoFinal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_sairDoJogo


    /**
    * @param args the command line arguments
    */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel areaVencedor;
    private javax.swing.JButton botaoSair;
    private javax.swing.JLabel imagemFinal;
    // End of variables declaration//GEN-END:variables
    private String nomeVencedor;

    public String getNomeVencedor() {
        return nomeVencedor;
    }

    public void setNomeVencedor(String winner) {
        this.nomeVencedor = winner + " Venceu!!!";
    }
}
